package com.qf.shoppingorder.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyFanoutExchangeConfig
 *
 * @author
 * @date 2024-03-20 9:54
 */
@Configuration
public class MyFanoutExchangeConfig {
    @Bean
    public FanoutExchange fanoutExchange() {
        FanoutExchange fanoutExchange = new FanoutExchange("fanout-exchange", true, false);
        return fanoutExchange;
    }

    @Bean
    public Queue fanoutQueue1() {
        Queue queue = new Queue("fanout.queue1", true, false, false);
        return queue;
    }

    @Bean
    public Queue fanoutQueue2() {
        Queue queue = new Queue("fanout.queue2", true, false, false);
        return queue;
    }

    @Bean
    public Binding fanoutQueue1Binding() {
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
    }

    @Bean
    public Binding fanoutQueue2Binding() {
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());
    }
}
